<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of UserAddresForm
 *
 * @author win 7
 */
class UserAddressSocial extends CFormModel {

    public $first_name;
    public $company;
    public $street1;
    public $city;
    public $country;
    public $postal_code;
    public $phone;
    public $status;

    public function rules() {
        return array(
            // username and password are required
            array('first_name, street1, city, phone', 'required'),
        );
    }

    public function CheckBeforeSaveCountry($attribute, $params) {
        if (!$this->hasErrors()) {
            if (GetContryCode() == 'VN') {
                if ($this->country == 704) {
                    return true;
                } else {
                    $this->addError('country', t('cms', 'Country is not valid.'));
                    return false;
                }
            } else {
                if ($this->country == 704) {
                    $this->addError('country', t('cms', 'Country is not valid.'));
                    return false;
                } else {
                    $UserCountries = UserCountries::model()->findByPk($this->country);
                    if ($UserCountries != null) {
                        return true;
                    } else {
                        $this->addError('country', t('cms', 'Country is not valid.'));
                        return false;
                    }
                }
            }
        }
    }

    public function attributeLabels() {
        return array(
            'first_name' => t('cms', 'Name: '),
            'company' => t('cms', 'Company: '),
            'street1' => t('cms', 'Street address: '),
            'city' => t('cms', 'City:'),
            'country' => t('cms', 'Country: '),
            'zip_code' => t('cms', 'Zipcode: '),
            'phone' => t('cms', 'Phone: '),
            'status' => t('cms', 'Status:'),
            'created_time' => t('cms', 'Created Time'),
            'updated_time' => t('cms', 'Updated Time'),
            'recent_login' => t('cms', 'Recent Login'),
            'user_activation_key' => t('cms', 'User Activation Key'),
            'status' => t('cms', 'Default address: '),
        );
    }

    //put your code here
}

?>
